﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using Telerik.Web.UI;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class PS_AbsenceRules_Popup : System.Web.UI.Page
    {
        private IEmployeeBLL employeeBLL = new EmployeeBLL();
        private IEmployeeTypeBLL employeeTypeBLL = new EmployeeTypeBLL();
        private IAbsenceRuleBLL ruleBLL = new AbsenceRuleBLL();
        private RadComboBox cmbEmployeeType;
        private KPIS.GERP.GHRMS.APP.Classes.Main main = new KPIS.GERP.GHRMS.APP.Classes.Main();

        protected void Page_Load(object sender, EventArgs e)
        {
            var empTypeSeqTemp = Convert.ToString(Request["EmpTypeSeq"]);
            int empTypeSeq;
            Int32.TryParse(empTypeSeqTemp, out empTypeSeq);
            if(empTypeSeq == 0) return;

            var empType = employeeTypeBLL.Select2().FirstOrDefault(o => o.Sequence == empTypeSeq);
            if(empType == null) return;

            lblEmployeeType.Text = empType.Name;
            var employees = employeeBLL.
                ListEmployeeByTypes(empTypeSeq.ToString(), "", "").
                Where(o => (o.QuitDate == null || o.QuitDate >= DateTime.Now) &&
                           o.RecordStatus != "D" &&
                           o.Status.Active && 
                           o.Position != null &&
                           o.RecordStatus != "D");

            lblEmpAmountInEmpType.Text = employees.Count().ToString();
            
            rptEmployeeInEmpTypeList.DataSource = employees;
            rptEmployeeInEmpTypeList.DataBind();
            
        }
    }
}